// src/api/axiosInstance.js
import axios from 'axios';

// ����һ�� Axios ʵ��
const axiosInstance = axios.create({
  baseURL: 'http://localhost:8080',  // ��� API ���� URL
  timeout: 5000,  // ����ʱ���ã�5�룩
  headers: {
    'Content-Type': 'application/json',  // Ĭ�Ϸ��� JSON ��ʽ������
  },
});

// 请求拦截器
axiosInstance.interceptors.request.use(
  (config) => {
      const token = localStorage.getItem('token');
      if (token) {
          config.headers.Authorization = `Bearer ${token}`;
      }
      return config;
  },
  (error) => {
      return Promise.reject(error);
  }
);



export default axiosInstance;
